package studyguide.ch05;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class HelloWorldMidlet extends MIDlet {

	public HelloWorldMidlet() {
		System.out.println("Running constructor");
	}
	
	protected void destroyApp(boolean unconditional)
			throws MIDletStateChangeException {
		System.out.println("Exiting application");
	}

	protected void pauseApp() {
		System.out.println("Pausing application");
	}

	protected void startApp() throws MIDletStateChangeException {
		System.out.println("Starting (or restarting) application");
		
		// Print MIDlet- and MicroEdition- properties
		System.out.println("MIDlet-Name:" + getAppProperty("MIDlet-Name"));
		System.out.println("MicroEdition-Profile:" + getAppProperty("MicroEdition-Profile"));
		
		// Print application property
		System.out.println("CustomProperty:" + getAppProperty("CustomProperty"));
		
		// Print system properties
		System.out.println("Platform:" + System.getProperty("microedition.platform"));
		System.out.println("Host name:" + System.getProperty("microedition.hostname"));
		System.out.println("Phone number:" + System.getProperty("wireless.messaging.sms.smsc"));
		System.out.println("JTWI Version:" + System.getProperty("microedition.jtwi.version"));
		
		// Print available comm ports
		System.out.println("Available comm ports:" + System.getProperty("microedition.commports"));
		
		Display d = Display.getDisplay(this);
		TextBox helloTB = new TextBox(
				"Hello - Title",
				"Hello World!",
				50,
				TextField.UNEDITABLE);
		d.setCurrent(helloTB);
	}

}
